//
//  THJCompanyHonorView.m
//  THJXHW
//
//  Created by 河南德艺 on 2017/11/4.
//  Copyright © 2017年 河南德艺. All rights reserved.
//

#import "THJCompanyHonorView.h"
#import <SDAutoLayout.h>
#import "ZBNetworking.h"
@implementation THJCompanyHonorView


+(THJCompanyHonorView*)instancView{
    
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:@"THJCompanyHonorView" owner:nil options:nil];
    return [nibView objectAtIndex:0];
}
- (id)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        
        // code your funciton...
        [self getData];
    }
    return self;
}
-(void)getData{
    NSString * token = [THJTools getToken];
    [ZBRequestManager requestWithConfig:^(ZBURLRequest *request){
        NSString * url = [NSString stringWithFormat:@"%@index.php?f=honor&r=honor&cid=%@",THJUrlDomain,self.cid];
        request.urlString = url;
        request.apiType = ZBRequestTypeRefresh;
        [request setValue:token forHeaderField:@"token"];
    }  success:^(id responseObject,apiType type){
        NSDictionary * receiveData = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
         NSLog(@"荣誉*-%@",receiveData);
        if([receiveData[@"status"] isEqual:@"200"]){
            NSLog(@"荣誉*-%@",receiveData);
            [self setUI];
            self.noticeLab.hidden = YES;
        }else{
            self.noticeLab.hidden = NO;
        }
    } failed:^(NSError *error){
        
    }];
}
-(void)setUI{
    UIScrollView * scroV = [[UIScrollView alloc] init];
    [self addSubview:scroV];
    scroV.bounces = NO;
    scroV.sd_layout
    .topSpaceToView(self, 200)
    .centerXEqualToView(self)
    .leftSpaceToView(self, 50)
    .rightSpaceToView(self,50)
    .heightIs(140);
    scroV.backgroundColor = SingleColor(brownColor);
    scroV.contentSize = CGSizeMake(180*3+20, 140);
    for(NSInteger i = 0;i<3;i++){
        UIImageView * imgv = [[UIImageView alloc] init];
        imgv.image = kGetImage(@"honor");
        imgv.frame =CGRectMake(i*(180+10), 0, 180, 140);
        [scroV addSubview:imgv];
    }
}
@end
